package org.pwwong.fxscalautils

import java.awt
import org.pwwong.fxscalautils.components.layouthints._
import org.pwwong.scalautils.signals._
import org.pwwong.scalautils.animation._

object Predef {
  
  class PX_PCT_Int(i:Int) extends PX(i) {
    def px = this
    def %% = PCT(i.toDouble)
  }
  
  class PX_PCT_Double(i:Double) extends PCT(i) {
    def px = PX(i.asInstanceOf[Int])
    def %% = this
  }
  
  def px(i:Int) = PX(i)
  def %(i:Double) = PCT(i)
  
  implicit def int2PX_PCT_Int(i: Int):PX_PCT_Int = new PX_PCT_Int(i)
  implicit def double2PX_PCT_Double(i: Double):PX_PCT_Double = new PX_PCT_Double(i)
  
  implicit def PCT2XPosition(i:PCT):XPosition[PCT] = XPosition[PCT](XOrigins.Left, i)
  implicit def PCT2YPosition(i:PCT):YPosition[PCT] = YPosition[PCT](YOrigins.Top, i)
  implicit def PX2XPosition(i:PX):XPosition[PX] = XPosition[PX](XOrigins.Left, i)
  implicit def PX2YPosition(i:PX):YPosition[PX] = YPosition[PX](YOrigins.Top, i)
  
  implicit def int2XPosition(i:Int):XPosition[PX] = XPosition[PX](XOrigins.Left, i px)
  implicit def int2YPosition(i:Int):YPosition[PX] = YPosition[PX](YOrigins.Top, i px)
     
  // Shape Predef
  implicit def intToSignalStroke(i:Int):Signal[awt.Stroke] = new ConstantSignal[awt.Stroke](new awt.BasicStroke(i))
  implicit def intToStroke(i:Int):awt.Stroke = new awt.BasicStroke(i)
  implicit def intToBasicStroke(i:Int):awt.BasicStroke = new awt.BasicStroke(i)
  
  // Layout Predefs
  // X
  val LeftOrigin = XOrigins.Left
  val CenterOrigin = XOrigins.Center
  val RightOrigin = XOrigins.Right
  val Left   = XPosition[PCT](LeftOrigin, 0.0 %%)
  val Center = XPosition[PCT](CenterOrigin, 0.0 %%)
  val Right  = XPosition[PCT](RightOrigin, 0.0 %%)
  
  // Y
  val TopOrigin = YOrigins.Top
  val MiddleOrigin = YOrigins.Middle
  val BottomOrigin = YOrigins.Bottom
  val Top    = YPosition[PCT](TopOrigin, 0 %%)
  val Middle = YPosition[PCT](MiddleOrigin, 0 %%)
  val Bottom = YPosition[PCT](BottomOrigin, 0 %%)
   
  object preferred extends Preferred
  object * extends Fill
  
}
